import request from '@u/request'
// 请求首页banner
const getHomeBanner = (params = {}) => {
  return request.get('/banner/list', {params})
}
// 请求分类列表
const fetchCates = (params = {}) => (
  request.get('/shop/goods/category/all', {params})
)
// 商品列表接口
const fetchItems = (params = {}) => (
  request.post('/shop/goods/list/v2', params)
)
// 获取商品详情
const fetchItemDetail = (id: string) => {
  return request.get('/shop/goods/detail', {params: {id}})
}

// 用户注册
const userRegister = (params = {}) => (
  request.post('/user/username/register', params)
)
// 用户登录
const userLogin = (params = {}) => (
  request.post('/user/username/login', params)
)

// 加入购物车
const addCart = (params = {}) => (
  request.post('/shopping-cart/add', params)
)
// 修改购物车购买数量
const changeItemNum = (params = {}) => {
  return request.post('/shopping-cart/modifyNumber', params)
}
export {
  getHomeBanner,
  fetchCates,
  fetchItems,
  fetchItemDetail,
  userRegister,
  userLogin,
  addCart,
  changeItemNum
}